package com.almori.hr.timetracker;
import java.io.Serializable;
import java.sql.*; 
import java.util.List;
/**
 * Java Bean connects Presentation layer with DAO
 * Nov 26, 2012, 2:11:40 PM
 * @author gcastillo, nbenavidez
 */
     
public class TimeTrackerBean implements Serializable {
    public TimeTrackerDAO dao = new TimeTrackerDAO();
    /**
     * Search and return a Employee by ced and password
     * @param ced
     * @param pass
     * @return employee with ced and pass
     * @throws java.sql.SQLException
     * @throws java.lang.Exception 
     */
    public Employee getEmployee(String ced, String pass)throws java.sql.SQLException,java.lang.Exception
    {
         Employee em = dao.getEmployeeByCedAndPassword(ced, pass);
         return em;
    }
     public Employee getEmployee(int id)throws java.sql.SQLException,java.lang.Exception
    {
         Employee em = dao.getEmployeeById(id);
         return em;
    }
    public String getDeptById(int id) throws  SQLException, Exception
    {
         return dao.getDeptById(id);
    }
 
    /**
     * Punch in or out depending on your current status the method will do both 
     * @param id
     * @param status
     * @param reason
     * @throws java.sql.SQLException
     * @throws java.lang.Exception 
     */
    public void punchTimecard(int id, String status,String reason)throws java.sql.SQLException,java.lang.Exception
    {
         dao.punchTimeCard(id, status, reason);
    }
    
    public void fixTimeCard(Timecard timeCard) throws Exception{
        dao.fixTimeCard(timeCard);
    }
    
    public List<Department> getDepartmentsList() throws java.sql.SQLException,java.lang.Exception
    {
         return dao.getDepartmentList();
    }
    
    public List<Employee> getEmployeeListByDept(int id_dept) throws java.sql.SQLException,java.lang.Exception
    {
         return dao.getEmployeeListByDept(id_dept);
    } 
     public List<Timecard> getDatesById(int id_empl) throws java.sql.SQLException,java.lang.Exception
    {
         return dao.getDatesByEmplId(id_empl);
    } 
     public List<Timecard> getDatesByDate(String date1, int id_empl) throws  SQLException, java.lang.Exception
     {
         return dao.getDatesByDate(date1,id_empl);
     }
     public Timecard getTimecardById(int id) throws java.sql.SQLException,java.lang.Exception
     {
         return dao.getTimecardById(id);
     }
     public void unlockAccount(int id_empl) throws java.sql.SQLException,java.lang.Exception
     {
         dao.unlock(id_empl);
     }
    
}//TimeTrackerBean
